﻿'****************************************************
'功能說明：Benner頁,bannerbg1.gif為本程式的底圖,size為60*1024px
'建立人員: andy
'建立日期：2011/1/31
'****************************************************
Imports System.Data

Partial Class ST_ST0010
    Inherits BasePage

    Protected Sub btnBackHome_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnBackHome.Click
        Dim strHomePage As String = "~/WebForm/Main/MainPage.aspx"
        Page.ClientScript.RegisterClientScriptBlock(GetType(BasePage), "StartPage", "<script language=JavaScript>  window.parent.frames[0].top.location = '" & ResolveUrl(strHomePage) & "';</script>")
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'btnLogout.Attributes.Add("onmouseover", "ChangeColor(this, '#fce031');")
        'btnLogout.Attributes.Add("onmouseout", "ChangeColor(this, '#ffffff');")
        'If Not IsPostBack() Then
        '    '顯示測試網站字樣
        '    If BS.DB.ExecuteScalar("Select ProductionFlag From SC_Parameter").ToString = "1" Then
        '        lblProductionFlag.Visible = False
        '    End If

        If Not IsPostBack() Then
            ddlUICulture.SelectedValue = GetUserLanguage()
        End If
        lblUserID.Text = ActualUID

        lblUserName.Text = ActualUserName


        If UID = ActualUID Then
            lblAgent.Visible = False
            btCloseAgency.Visible = False
        Else
            lblAgent.Visible = True
            lblAgent.Text = "目前代理：" & Session("UID").ToString() & "　" & Session("UserName").ToString()
            btCloseAgency.Visible = True
            txtStatus.Text = "1" '代理中

            'TODO 往後看是否要判斷代理人資訊

            '判斷代理種類 -- 以後要再加判斷

            'Dim objSC As New SC

            'Using dt As DataTable = objSC.getAgency(UserProfile.UserID, UserProfile.ActUserID).Tables(0)
            '    If dt.Rows.Count > 0 Then
            '        txtAgencyType.Text = dt.Rows(0).Item("AgencyType").ToString()
            '        If txtAgencyType.Text = "0" Then
            '            lb_1.Visible = False
            '            lb_2.Visible = False
            '            lb_3.Visible = True
            '        Else
            '            lb_3.Visible = False
            '        End If
            '        lblAgent.Visible = True
            '        lblAgent.Text = "目前代理：" & UserProfile.UserID & "　" & UserProfile.UserName
            '        btCloseAgency.Visible = True
            '        txtStatus.Text = "1" '代理中

            '    Else
            '        If UserProfile.ActGroupID.Item("22") IsNot Nothing Then
            '            txtAgencyType.Text = "1"
            '            lb_3.Visible = False
            '            lblAgent.Visible = True
            '            lblAgent.Text = "目前代理：" & UserProfile.UserID & "　" & UserProfile.UserName
            '            btCloseAgency.Visible = True
            '            txtStatus.Text = "1" '代理中
            '        Else
            '            Dim myUserInfo As UserInfo = CType(Session("UserInfo"), UserInfo)
            '            myUserInfo.UserID = myUserInfo.ActUserID
            '            myUserInfo.UserName = myUserInfo.ActUserName
            '            myUserInfo.DeptID = myUserInfo.ActDeptID
            '            myUserInfo.DeptName = myUserInfo.ActDeptName
            '            myUserInfo.OrganID = myUserInfo.ActOrganID
            '            myUserInfo.OrganName = myUserInfo.ActOrganName
            '            myUserInfo.BusinessID = myUserInfo.ActBusinessID
            '            myUserInfo.GroupID = myUserInfo.ActGroupID

            '            lblAgent.Visible = False
            '            btCloseAgency.Visible = False
            '            lb_3.Visible = False
            '        End If
            '    End If
            'End Using

        End If
    End Sub

    Protected Sub btCloseAgency_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btCloseAgency.Click
        'Dim myUserInfo As UserInfo = CType(Session(BS.MySettings.UserProfileSessionName), UserInfo)

        UID = ActualUID
        UserName = ActualUserName


        lblUserID.Text = UID

        lblUserName.Text = UserName


        If UID = ActualUID Then
            lblAgent.Visible = False
            btCloseAgency.Visible = False
        Else
            lblAgent.Visible = True
            lblAgent.Text = "目前代理：" & Session("UID").ToString() & "　" & Session("UserName").ToString()
            btCloseAgency.Visible = True
        End If


        'myUserInfo.UserName = myUserInfo.ActualUserName
        'myUserInfo.DeptID = myUserInfo.ActualDeptID
        'myUserInfo.DeptName = myUserInfo.ActualDeptName
        'myUserInfo.OrganID = myUserInfo.ActualOrganID
        'myUserInfo.OrganName = myUserInfo.ActualOrganName
        'myUserInfo.GroupID = myUserInfo.ActualGroupID

        'lblAgent.Visible = False
        'btCloseAgency.Visible = False
        'lb_2.Visible = True

        'txtStatus.Text = "0" '結束代理
        'txtAgencyType.Text = ""
        Page.ClientScript.RegisterClientScriptBlock(GetType(BasePage), "StartPage", "<script language=JavaScript>  window.top.location='MainPage.aspx';</script>")
        'BS.Utility.RunClientScript(Me, "window.top.location='" & ResolveUrl(BS.MySettings.StartPage) & "';")
    End Sub

    Protected Sub btnLogout_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLogout.Click
        'UnLockAll() '解除鎖定
        'BS.Utility.RunClientScript(Me, "window.top.location = '" & ResolveUrl("~/Default.aspx") & "';")
    End Sub

    Protected Sub ddlUICulture_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlUICulture.SelectedIndexChanged
        SetUserLanguage(ddlUICulture.SelectedValue)
        Dim bbl As OAMS.BBL.UsersBBL = New OAMS.BBL.UsersBBL()
        bbl.SetLanguage(ActualUID, ddlUICulture.SelectedValue, dbName)
        Page.ClientScript.RegisterClientScriptBlock(GetType(BasePage), "StartPage", "<script language=JavaScript>  window.top.location='MainPage.aspx';</script>")
    End Sub
End Class
